global.SleepData = db.collection("Menstruation.SleepData");
module.exports = {
	get: function(req, res) {
		co(function*() {
			var sleepCount = yield SleepData.count();
			(sleepCount < 4) ? sleepCount = 0: sleepCount = sleepCount - 4;
			var docs = yield SleepData.find({}).skip(sleepCount).limit(4).toArray();
			res.send(docs);
			console.log(docs)
		}).catch(e => {
			console.log(e);
			res.send({});
		});
	},
	post: function(req, res) {
		var q = req.body;
		console.log("error:", q);
		res.end();
	}
}